package command

import (
	"fmt"
	"code.google.com/p/microtool/util/stringset"
)

// The list command outputs a sorted list of all active commands within
// Microtool.
var list = &Command{
	Name: "list",
	Info: "List all active commands.",
	Fn:   listImpl,
}

// listImpl implements the list command.
func listImpl(_, _ string) error {
	ss := stringset.NewSet()
	for name := range Active {
		ss.Add(name)
	}
	for _, name := range ss.OrderedSlice() {
		fmt.Printf("%-20s  %s\n", name, Active[name].Info)
	}
	return nil
}
